package com.bwie.controller;

import com.bwie.service.UserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginVo;
import com.bwie.vo.MenuVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: tsh
 * @Date: 2025/7/31 09:15
 * @Description: TODO
 **/
@RestController
@RequestMapping("/auth/index")
@Api(tags = "认证微服务")
public class IndexController {
    @Autowired
    UserService userService;

    /**
     * @description 登录
     * @params
     * @param loginVo
     * @return com.bwie.utils.R
     * @author tsh
     * @date 2025/7/31 9:22
     */
    @PostMapping("/login")
    @ApiOperation(value = "登录")
    public R login(@RequestBody LoginVo loginVo){
        return userService.login(loginVo);
    }
    /**
     * @description  根据邮箱获取登录用户
     * @params
     * @param email
     * @return com.bwie.utils.R
     * @author tsh
     * @date 2025/7/31 9:37
     */
    @PostMapping("/getUserByEmail/{email}")
    @ApiOperation(value = "根据邮箱获取登录用户")
    public R getUserByEmail(@PathVariable("email") String email){
        return userService.getUserByEmail(email);
    }


    /**
     * @description 查询菜单
     * @params
     * @param menuVo
     * @return com.bwie.utils.R
     * @author tsh
     * @date 2025/7/31 11:04
     */
    @PostMapping("/getMenuList")
    @ApiOperation(value = "查询菜单")
    public R getMenuList(@RequestBody MenuVo menuVo){
        return userService.getMenuList(menuVo);
    }
}
